%This code produces Figure 2 in the paper.

ret = transpose(-0.2:0.001:0.2);       %hypothetical return without guidance bias
ret = [ret, NaN(size(ret,1),4)];       %stores optimal guidance bias for each return

for k = 1:4

%baseline scenario
lambda = 1.25;
beta   = 0.75;
c      = 2;
sigma  = 40;
P0     = 100;

if k==2; beta  = 0.65;end %higher presence preference
if k==3; sigma = 50;  end %higher payoff uncertainty
if k==4; c     = 1;   end %lower personal costs

b1  = (1       -beta*sqrt(1+lambda))/(beta/sigma*(lambda+2*c));
b2  = (1+lambda-beta*sqrt(1+lambda))/(beta/sigma*(lambda+2*c));

for j=1:length(ret)
    
    P1unbiased = P0*(ret(j,1)+1);
    if     P0-P1unbiased < b1
        ret(j,k+1) = b1;
    elseif P0-P1unbiased > b2
        ret(j,k+1) = b2;
    else
        ret(j,k+1) = P0-P1unbiased;
    end
end
end


plot(ret(:,1)*100,ret(:,2),'linestyle','-','Color', [0.3  0.3  0.3],'LineWidth',3)
hold on
plot(ret(:,1)*100,ret(:,3),'linestyle','-.','Color', [0  0.5 0.5],'LineWidth',2)
plot(ret(:,1)*100,ret(:,4),'linestyle',':','Color', [0.5  0  0.5],'LineWidth',2)
plot(ret(:,1)*100,ret(:,5),'linestyle','--','Color', [0.5  0.5  0],'LineWidth',2)
hold off
set(gcf, 'Position',  [100, 100, 1000, 560])
set(gca,'FontSize',14)
set(gca,'fontname','times')
xlabel("hypothetical stock return from $t_0$ to $t_1$ for $b=0$",'Interpreter','Latex')
ylabel('optimal guidance bias $b^*$','Interpreter','Latex')
xtickformat('percentage')

legend('baseline scenario','lower $\beta$','higher $\sigma$','lower $c$','Interpreter','Latex','FontSize',15, 'Location','northeast','Orientation','vertical')
saveas(gcf,'GuidanceModelPlot.eps','epsc')



%Alternative Online Appendix model where guidance bias reduces uncertainty

ret = transpose(-0.2:0.001:0.2);       %hypothetical return without guidance bias
ret = [ret, NaN(size(ret,1),4)];       %stores optimal guidance bias for each return

for k = 1:4

%baseline scenario
lambda = 1.25;
beta   = 0.75;
c      = 2;
sigma  = 40;
P0     = 100;

kappa = 1-(2*sqrt(1+lambda)-2)/lambda;

if k==2; beta  = 0.65;end %higher presence preference
if k==3; sigma = 50;  end %higher payoff uncertainty
if k==4; c     = 1;   end %lower personal costs

b1  = (1       -beta*sqrt(1+lambda))/(beta/sigma*(lambda*(1+kappa)+2*c/(1+kappa)));
b2  = (1       -beta*sqrt(1+lambda))/(beta/sigma*(lambda*(1-kappa)+2*c/(1-kappa)));
b3  = (1+lambda-beta*sqrt(1+lambda))/(beta/sigma*(lambda*(1+kappa)+2*c/(1+kappa)));
b4  = (1+lambda-beta*sqrt(1+lambda))/(beta/sigma*(lambda*(1-kappa)+2*c/(1-kappa)));

for j=1:length(ret)
    
    P1unbiased = P0*(ret(j,1)+1);
    if     b1>=0 && P0-P1unbiased < (1+kappa)*b1
        ret(j,k+1) = b1;
    elseif b2< 0 && P0-P1unbiased < (1-kappa)*b2
        ret(j,k+1) = b2;
    elseif b3>=0 && P0-P1unbiased > (1+kappa)*b3
        ret(j,k+1) = b3;
    elseif b4< 0 && P0-P1unbiased > (1-kappa)*b4
        ret(j,k+1) = b4;
    else
        if P0-P1unbiased >=0
            ret(j,k+1) = (P0-P1unbiased)/(1+kappa);
        else
            ret(j,k+1) = (P0-P1unbiased)/(1-kappa);
        end
    end
end
end


plot(ret(:,1)*100,ret(:,2),'linestyle','-','Color', [0.3  0.3  0.3],'LineWidth',3)
hold on
plot(ret(:,1)*100,ret(:,3),'linestyle','-.','Color', [0  0.5 0.5],'LineWidth',2)
plot(ret(:,1)*100,ret(:,4),'linestyle',':','Color', [0.5  0  0.5],'LineWidth',2)
plot(ret(:,1)*100,ret(:,5),'linestyle','--','Color', [0.5  0.5  0],'LineWidth',2)
hold off
set(gcf, 'Position',  [100, 100, 1000, 560])
set(gca,'FontSize',14)
set(gca,'fontname','times')
xlabel("hypothetical stock return from $t_0$ to $t_1$ for $b=0$",'Interpreter','Latex')
ylabel('optimal guidance bias $b^*$','Interpreter','Latex')
xtickformat('percentage')

legend('baseline scenario','lower $\beta$','higher $\sigma$','lower $c$','Interpreter','Latex','FontSize',15, 'Location','northeast','Orientation','vertical')

saveas(gcf,'GuidanceModelPlot_OA.eps','epsc')
